import React from 'react';

import {
  HashRouter as Router,
  Switch,
  Route,
  Redirect,
} from 'react-router-dom';
import 'index.scss';
import Money from './view/Money';
import Statistics from './view/Statistics';
import Tags from './view/Tags/Tags';
import NoMatch from './view/NoMatch';
import {TagEditor} from './view/Tags/TagEditor';
import {TagAdder} from './view/Tags/TagAdder';
import {RecordEditor} from 'view/Statistics/RecordEditor';

let importAll = (requireContext: __WebpackModuleApi.RequireContext) => requireContext.keys().forEach(requireContext);
try {importAll(require.context('icons', true, /\.svg$/));} catch (error) {console.log(error);}


function App() {
  return (
    <Router>
      <Switch>
        <Route exact path="/tags">
          <Tags/>
        </Route>
        <Route exact path="/tags/:tagIdString">
          <TagEditor/>
        </Route>
        <Route exact path="/addTag">
          <TagAdder/>
        </Route>
        <Route exact path="/money">
          <Money/>
        </Route>
        <Route exact path="/statistics">
          <Statistics/>
        </Route>
        <Route exact path="/statistics/:recordIdString">
          <RecordEditor/>
        </Route>
        <Redirect exact from="/" to="/money"/>
        <Route path="*">
          <NoMatch/>
        </Route>
      </Switch>
    </Router>
  );
}

export default App;